package com.jewaton.auth.dao.impl;


import com.jewaton.auth.base.impl.BaseDaoImpl;
import com.jewaton.auth.dao.ResourcesDao;
import com.jewaton.auth.entity.ResourceRoles;
import com.jewaton.auth.entity.Resources;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 资源DAO层实现类
 */
@Repository("resourcesDao")
public class ResourcesDaoImpl extends BaseDaoImpl<Resources> implements ResourcesDao
{

	public List<Resources> findAll() {
		return getSqlSession().selectList("resources.findAll");
	}
	//<!-- 根据用户Id获取该用户的权限-->
	public List<Resources> getUserResources(String userId){
		return getSqlSession().selectList("resources.getUserResources",userId);
	}
	//<!-- 根据用户名获取该用户的权限-->
	public List<Resources> getResourcesByUserName(String username){
		return getSqlSession().selectList("resources.getResourcesByUserName",username);
	}

    //<!-- 根据用户名获取该用户的菜单-->
    public List<Resources> getMenusByUserName(String username){
        return getSqlSession().selectList("resources.getMenusByUserName",username);
    }
	//<!-- 根据角色Id获取该用户的权限-->
	public List<Resources> getRoleResources(String roleId){
		return getSqlSession().selectList("resources.getRoleResources",roleId);
	}
	public void saveRoleRescours(ResourceRoles resourceRoles){
		 getSqlSession().insert("resources.saveRoleRescours",resourceRoles);
	}
	public void deleteRoleRescours(String roleId){
		getSqlSession().delete("resources.deleteRoleRescours",roleId);
	}
}
